package com.acme.entity.util;

import java.io.Serializable;
import java.util.Collection;
import javax.swing.event.ChangeListener;

public abstract class EntityBean<E extends EntityBean> implements Serializable, Cloneable {

    protected final ChangeSupport support = new ChangeSupport(this);

    public EntityBean(){
    support.addChangeListener(DBManager.getListener());
    }

    public void addChangeListener(ChangeListener listener) {
        support.addChangeListener(listener);
    }

    public void removeChangeListener(ChangeListener listener) {
        support.removeChangeListener(listener);
    }

    protected <T> void mergeListContent(ChangeSupportList<T> lista, Collection<T> elements) {
        lista.clear();
        lista.addAll(lista);
    }

    @Override
    public abstract E clone();

    public abstract void merge(E other);

}
